using System;
using System.Collections.Generic;


namespace DataObjects
{
	[Serializable]
	public class Funds: IEquatable<Funds>
	{

		#region Private Members

		private string _type; 
		private string _unit; 
		private DateTime? _date_input; 
		private double _money; 
		private string _remark; 		
		#endregion

		#region Constructor

		public Funds()
		{
			_type = String.Empty; 
			_unit = String.Empty; 
			_date_input = new DateTime?(); 
			_money = new double(); 
			_remark = String.Empty; 
		}
		#endregion // End of Default ( Empty ) Class Constuctor

		#region Required Fields Only Constructor
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public Funds(
			string type, 
			string unit)
			: this()
		{
			_type = type;
			_unit = unit;
			_date_input = null;
			_money = 0;
			_remark = String.Empty;
		}
		#endregion // End Constructor

		#region Public Properties
			
		public virtual string Type
		{
			get
			{ 
				return _type;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for Type", value, "null");
				
				if(  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for Type", value, value.ToString());
				
				_type = value;
			}
		}
			
		public virtual string Unit
		{
			get
			{ 
				return _unit;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for Unit", value, "null");
				
				if(  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for Unit", value, value.ToString());
				
				_unit = value;
			}
		}
			
		public virtual DateTime? DateInput
		{
			get
			{ 
				return _date_input;
			}
			set
			{
				_date_input = value;
			}

		}
			
		public virtual double Money
		{
			get
			{ 
				return _money;
			}
			set
			{
				_money = value;
			}

		}
			
		public virtual string Remark
		{
			get
			{ 
				return _remark;
			}

			set	
			{	
				if(  value != null &&  value.Length > 200)
					throw new ArgumentOutOfRangeException("Invalid value for Remark", value, value.ToString());
				
				_remark = value;
			}
		}
			
				
		#endregion 

		#region Public Functions

		#endregion //Public Functions

		#region Equals And HashCode Overrides
		/// <summary>
		/// local implementation of Equals based on unique value members
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
			Funds castObj = (Funds)obj; 
			return ( castObj != null ) &&
				( this._type == castObj.Type ) &&
				( this._unit == castObj.Unit );
		}
		
		/// <summary>
		/// local implementation of GetHashCode based on unique value members
		/// </summary>
		public override int GetHashCode()
		{
			
			int hash = 57; 
			hash = 27 ^ hash ^ _type.GetHashCode();
			hash = 27 ^ hash ^ _unit.GetHashCode();
			return hash; 
		}
		#endregion
		
		#region IEquatable members

		public bool Equals(Funds other)
		{
			if (other == this)
				return true;
		
			return ( other != null ) &&
				( this._type == other.Type ) &&
				( this._unit == other.Unit );
				   
		}

		#endregion
		
	}
}
